package com.yesun.dcm.config.spring.handler;

import com.yesun.dcm.config.spring.*;
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
import java.util.HashSet;
import java.util.Set;

/**
 * @author chunmingdeng 2017/9/27 Create.
 * @version 1.0
 * @copyright (c) YESUN. All Rights Reserved.
 * @description: 自定义spring config中的元素节点
 */
public class DcmNamespaceHandler extends NamespaceHandlerSupport {

    //协议名称
    public final static Set<String> protocolDefineNames = new HashSet<String>();
    //注册中心名称
    public final static Set<String> registryDefineNames = new HashSet<String>();
    //服务名称
    public final static Set<String> serviceDefineName = new HashSet<String>();


    /**
     * 给自定义元素节点指定解析类
     */
    @Override
    public void init() {
        registerBeanDefinitionParser("registry", new DcmBeanDefinitionParser(RegistryConfig.class, true));
        registerBeanDefinitionParser("protocol", new DcmBeanDefinitionParser(ProtocolConfig.class, true));
        registerBeanDefinitionParser("service", new DcmBeanDefinitionParser(ServiceConfigBean.class, true));
        registerBeanDefinitionParser("referer", new DcmBeanDefinitionParser(RefererConfigBean.class, false)); //false
    }
}
